package com.eoner.managerlibrary.weixin;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.content.FileProvider;

import com.tencent.mm.opensdk.openapi.WXAPIFactory;

import java.io.File;

/**
 * @auther hjian
 * @date 2020/11/26.
 */
public class WeiXinManager {

    public static final String APP_ID = "wx8031a358899ba015";
    public static final String SECRET = "bad93415f4959a2e7ece6b65230fcd76";
    public static final String ORIGINAL_ID = "gh_0d1a6e2f60fa";// 小程序原始id

    // 判断微信版本是否为7.0.13及以上
    public static boolean checkVersionValid(Context context) {
        return WXAPIFactory.createWXAPI(context, APP_ID).getWXAppSupportAPI() >= 0x27000D00;
    }

    // 判断Android版本是否7.0及以上
    public static boolean checkAndroidNotBelowN() {
        return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N;
    }

    public static String getFileUri(Context context, File file) {
        if (file == null || !file.exists()) {
            return null;
        }
        Uri contentUri = FileProvider.getUriForFile(context,
                "com.masterclient.app.fileprovider",
                file);
        context.grantUriPermission("com.tencent.mm",
                contentUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);

        return contentUri.toString();
    }


}
